package com.zhoutao.blog.seven.utils;

import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

public class TimeParseUtils {

    public final static DateTimeFormatter DEFAULT = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");

    private TimeParseUtils() {
    }

    /**
     * 根据时间戳格式化
     *
     * @param timestamp
     * @return
     */
    public static LocalDateTime parse(Long timestamp) {
        if (timestamp == null || timestamp < 0) {
            return null;
        }

        return Instant.ofEpochMilli(timestamp).atZone(ZoneId.systemDefault()).toLocalDateTime();

    }
}
